{% extends "base/base.html" %}{% load i18n static %}
{% block content %}
    <h2>{% trans "Upload" %} {{ resource_name }}</h2>

    {% if form.non_field_errors %}
    <div class="alert alert-error">
        <button type="button" class="close" data-dismiss="alert">&times;</button>
        {% for error in form.non_field_errors %}
            <p>{{ error }}</p>
        {% endfor %}
    </div>
    {% endif %}

    <form method="post" enctype="multipart/form-data">
        {% csrf_token %}
        {% include "base/form_snippet.html" %}

        <div class="license-agreement">
            <label class="checkbox">
                <input type="checkbox" required> I confirm that I own these materials and have the rights to share them, including any embedded content, under the <a href="https://creativecommons.org/publicdomain/zero/1.0/" target="_blank">CC-0 license</a>.
            </label>
        </div>

        <button class="btn btn-primary" id="licenseAgreed" type="submit">{% trans "Upload" %}</button>
    </form>

    <script type="text/javascript" src="{% static 'js/resource_upload.js' %}"></script>

    <script>
        // check filesize
        $('#id_file').bind('change', function() {
            let maxFileSize = 1000000;
            let fileSize = this.files[0].size
            if (fileSize > maxFileSize){
                alert('You have selected a file that is more than 1mb, files larger than this are not supported.');
                $('#id_file').val('');
            };
        });
    </script>
{% endblock %}